<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Lightweight OS (LWOS): lwos.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Lightweight OS (LWOS)
   
   </div>
   <div id="projectbrief">A diminutive operating system</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Defines</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">lwos.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Header for LWOS programs.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;setjmp.h&gt;</code><br/>
</div>
<p><a href="lwos_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct__task.html">_task</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Each row of the <em>task_table</em> contains data about the task.  <a href="struct__task.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a12e3ca8335f5d679110ad929d874a1be">TASK_TABLE</a>&#160;&#160;&#160;<a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> <a class="el" href="lwos_8h.html#a68b9925cf8d8141dbab91504b96f9ffd">task_table</a>[]= {</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to create task table and other global vars.  <a href="#a12e3ca8335f5d679110ad929d874a1be"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a82a4e5d2eb531e20baab4834d706dced">TASK_DEF</a>(rdy, func)&#160;&#160;&#160;{ rdy, func, NULL, NULL, 0, 0, 0 },</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a7314ad161e64e792b24b3ac3886a1aaf">TASK_TABLE_END</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Macro to end the task table and define some more globals.  <a href="#a7314ad161e64e792b24b3ac3886a1aaf"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a>(n)&#160;&#160;&#160;longjmp(<a class="el" href="lwos_8h.html#a3b6d2a771ddc14909fe529c79622be1f">task_current</a>-&gt;yieldbuf,(n)+1)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Yield to a specific task (or next lowest priority that is ready)  <a href="#ab169de39462599fcb59ff956cbbd6b5b"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#af114a3dc72933128fbbfbf95f13df1d8">task_yield</a>()&#160;&#160;&#160;<a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a>(0)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Yield normally.  <a href="#af114a3dc72933128fbbfbf95f13df1d8"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a22326027822d084bf9b37958576ae00c">task_yield_next</a>()&#160;&#160;&#160;<a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a>(<a class="el" href="lwos_8h.html#a7c6e943398bf748ba97367e4b250d56f">task_num</a>+1)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Yield to next highest priority task that is ready.  <a href="#a22326027822d084bf9b37958576ae00c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a97f92c459963aa372df2340eb5c22cd0">task_storage</a>(dstruct)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#aa8e98f2df3d1969955902e2c7f64faec">task_waitn</a>(sem, n)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#ad45c617c8336b61e63ab5a2aebaeb0c0">task_wait</a>(sem)&#160;&#160;&#160;<a class="el" href="lwos_8h.html#aa8e98f2df3d1969955902e2c7f64faec">task_waitn</a>(sem,1)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a62b952fe434a16273d788c45afc0b6c8">task_release</a>(sem)&#160;&#160;&#160;sem=0</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#ade1c770559ecd37b9fd176fbf8e79e0b">task_decr</a>(sem)&#160;&#160;&#160;--sem</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a5fb5333b34abf3b33e9f45d70662c5d0">task_sleep</a>(ticks)</td></tr>
<tr><td colspan="2"><h2><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="struct__task.html">_task</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Each row of the <em>task_table</em> contains data about the task.  <a href="#af41b315a18a5782b8182db98ab85c5b7"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bce">TaskState</a> { <a class="el" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bcea52340c1844b9c87b6c965569f21d72f1">TASK_STOPPED</a> = -1, 
<a class="el" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bceaebcd951a6127c3c50a4f197b2b637793">TASK_READY</a> = 0, 
<a class="el" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bceaed346ef57a002d0957c75cb3a8888025">TASK_WAIT</a> = 1
 }</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">State of a task (stopped, ready, or waiting on an event)  <a href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bce">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a2d5f6c88428ff65ce252e63964752e76">task_init</a> (void)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Start LWOS -- typically called from default main.  <a href="#a2d5f6c88428ff65ce252e63964752e76"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="var-members"></a>
Variables</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#abbf01dbc8a3f47fd82f6c2afd53987ca">task_tick</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">User defined tick counter (must be signed)  <a href="#abbf01dbc8a3f47fd82f6c2afd53987ca"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a48e853cd9284d45e9af1203802dad496">task_max</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Number of entries in the task table.  <a href="#a48e853cd9284d45e9af1203802dad496"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a3b6d2a771ddc14909fe529c79622be1f">task_current</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Pointer to current task.  <a href="#a3b6d2a771ddc14909fe529c79622be1f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a7c6e943398bf748ba97367e4b250d56f">task_num</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Current running task (as an index into <em>task_table</em>)  <a href="#a7c6e943398bf748ba97367e4b250d56f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="lwos_8h.html#a68b9925cf8d8141dbab91504b96f9ffd">task_table</a> []</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">The table of tasks.  <a href="#a68b9925cf8d8141dbab91504b96f9ffd"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Header for LWOS programs. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Al Williams </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>30 Oct 2012 Lightweight OS by Al Williams (<a href="mailto:al.williams@awce.com">al.williams@awce.com</a>) A very simple "OS" written in ordinary C that provides cooperative multitasking and is simple enough to port to very small microcontrollers that have a C compiler</dd></dl>
<p>The lwos file has its own <a class="el" href="lwos_8c.html#a0ddf1224851353fc92bfbff6f499fa97" title="The LWOS-defined main just calls task_init.">main()</a> (although you can suppress this by defining LWOS_NOMAIN.</p>
<p>This file is part of LWOS.</p>
<p>LWOS is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</p>
<p>You should have received a copy of the GNU Lesser General Public License along with this program. If not, see &lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;. </p>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="ade1c770559ecd37b9fd176fbf8e79e0b"></a><!-- doxytag: member="lwos.h::task_decr" ref="ade1c770559ecd37b9fd176fbf8e79e0b" args="(sem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#ade1c770559ecd37b9fd176fbf8e79e0b">task_decr</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem</td><td>)</td>
          <td>&#160;&#160;&#160;--sem</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Decrement a wait variable </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>- Name of wait variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a82a4e5d2eb531e20baab4834d706dced"></a><!-- doxytag: member="lwos.h::TASK_DEF" ref="a82a4e5d2eb531e20baab4834d706dced" args="(rdy, func)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a82a4e5d2eb531e20baab4834d706dced">TASK_DEF</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">rdy, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">func&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;{ rdy, func, NULL, NULL, 0, 0, 0 },</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro to define a row in the task table </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">rdy</td><td>- Task ready state (usually TASK_READY) </td></tr>
    <tr><td class="paramname">func</td><td>- The task function </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a62b952fe434a16273d788c45afc0b6c8"></a><!-- doxytag: member="lwos.h::task_release" ref="a62b952fe434a16273d788c45afc0b6c8" args="(sem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a62b952fe434a16273d788c45afc0b6c8">task_release</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem</td><td>)</td>
          <td>&#160;&#160;&#160;sem=0</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Release a wait variable </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>- Name of wait variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a5fb5333b34abf3b33e9f45d70662c5d0"></a><!-- doxytag: member="lwos.h::task_sleep" ref="a5fb5333b34abf3b33e9f45d70662c5d0" args="(ticks)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a5fb5333b34abf3b33e9f45d70662c5d0">task_sleep</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">ticks</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">{ <a class="code" href="lwos_8c.html#a3b6d2a771ddc14909fe529c79622be1f" title="Pointer to current task.">task_current</a>-&gt;<a class="code" href="struct__task.html#a9089f005616ac7d832860662e7c49c0a" title="If waiting for a tick count, here it is.">wake</a>=<a class="code" href="lwos_8c.html#abbf01dbc8a3f47fd82f6c2afd53987ca" title="User defined tick counter (must be signed)">task_tick</a>+ticks,           \
      task_current-&gt;state=<a class="code" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bceaed346ef57a002d0957c75cb3a8888025">TASK_WAIT</a>;     <a class="code" href="lwos_8h.html#af114a3dc72933128fbbfbf95f13df1d8" title="Yield normally.">task_yield</a>();   }
</pre></div><p>Sleep for given tick count </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ticks</td><td>- Number of ticks to wait </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a97f92c459963aa372df2340eb5c22cd0"></a><!-- doxytag: member="lwos.h::task_storage" ref="a97f92c459963aa372df2340eb5c22cd0" args="(dstruct)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a97f92c459963aa372df2340eb5c22cd0">task_storage</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">dstruct</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">(dstruct *)(!<a class="code" href="lwos_8c.html#a3b6d2a771ddc14909fe529c79622be1f" title="Pointer to current task.">task_current</a>-&gt;<a class="code" href="struct__task.html#a4d013bae5c755de564a24eab1d4f412b" title="Pointer to task local storage (see task_alloc)">taskdata</a>?     \
               <a class="code" href="lwos_8c.html#a3b6d2a771ddc14909fe529c79622be1f" title="Pointer to current task.">task_current</a>-&gt;<a class="code" href="struct__task.html#a4d013bae5c755de564a24eab1d4f412b" title="Pointer to task local storage (see task_alloc)">taskdata</a>=calloc(1,<span class="keyword">sizeof</span>(dstruct)): \
               task_current-&gt;taskdata)
</pre></div><p>Allocate or fetch task local </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">dstruct</td><td>- name of data type for storage </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a12e3ca8335f5d679110ad929d874a1be"></a><!-- doxytag: member="lwos.h::TASK_TABLE" ref="a12e3ca8335f5d679110ad929d874a1be" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a12e3ca8335f5d679110ad929d874a1be">TASK_TABLE</a>&#160;&#160;&#160;<a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> <a class="el" href="lwos_8h.html#a68b9925cf8d8141dbab91504b96f9ffd">task_table</a>[]= {</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Macro to create task table and other global vars. </p>

</div>
</div>
<a class="anchor" id="a7314ad161e64e792b24b3ac3886a1aaf"></a><!-- doxytag: member="lwos.h::TASK_TABLE_END" ref="a7314ad161e64e792b24b3ac3886a1aaf" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a7314ad161e64e792b24b3ac3886a1aaf">TASK_TABLE_END</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">};        \
  unsigned <a class="code" href="lwos_8h.html#a48e853cd9284d45e9af1203802dad496" title="Number of entries in the task table.">task_max</a>=<span class="keyword">sizeof</span>(<a class="code" href="lwos_8h.html#a68b9925cf8d8141dbab91504b96f9ffd" title="The table of tasks.">task_table</a>)/<span class="keyword">sizeof</span>(task_table[0]);
</pre></div>
<p>Macro to end the task table and define some more globals. </p>

</div>
</div>
<a class="anchor" id="ad45c617c8336b61e63ab5a2aebaeb0c0"></a><!-- doxytag: member="lwos.h::task_wait" ref="ad45c617c8336b61e63ab5a2aebaeb0c0" args="(sem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#ad45c617c8336b61e63ab5a2aebaeb0c0">task_wait</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem</td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="lwos_8h.html#aa8e98f2df3d1969955902e2c7f64faec">task_waitn</a>(sem,1)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Wait on a flag to be set to zero </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>- Name of wait variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="aa8e98f2df3d1969955902e2c7f64faec"></a><!-- doxytag: member="lwos.h::task_waitn" ref="aa8e98f2df3d1969955902e2c7f64faec" args="(sem, n)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#aa8e98f2df3d1969955902e2c7f64faec">task_waitn</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">n&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<b>Value:</b><div class="fragment"><pre class="fragment">{ sem=1, <a class="code" href="lwos_8c.html#a3b6d2a771ddc14909fe529c79622be1f" title="Pointer to current task.">task_current</a>-&gt;<a class="code" href="struct__task.html#ad5da6557d0c1af58ee967fee5cf48614" title="If waiting for a semaphore, point to it.">wait</a>=&amp;sem, \
      task_current-&gt;state=<a class="code" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bceaed346ef57a002d0957c75cb3a8888025">TASK_WAIT</a>; <a class="code" href="lwos_8h.html#af114a3dc72933128fbbfbf95f13df1d8" title="Yield normally.">task_yield</a>();   }
</pre></div><p>Wait on a flag to be set to zero </p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>- Name of wait variable </td></tr>
    <tr><td class="paramname">n</td><td>- Value to set in wait variable </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="af114a3dc72933128fbbfbf95f13df1d8"></a><!-- doxytag: member="lwos.h::task_yield" ref="af114a3dc72933128fbbfbf95f13df1d8" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#af114a3dc72933128fbbfbf95f13df1d8">task_yield</a></td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a>(0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Yield normally. </p>

</div>
</div>
<a class="anchor" id="a22326027822d084bf9b37958576ae00c"></a><!-- doxytag: member="lwos.h::task_yield_next" ref="a22326027822d084bf9b37958576ae00c" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#a22326027822d084bf9b37958576ae00c">task_yield_next</a></td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td>&#160;&#160;&#160;<a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a>(<a class="el" href="lwos_8h.html#a7c6e943398bf748ba97367e4b250d56f">task_num</a>+1)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Yield to next highest priority task that is ready. </p>

</div>
</div>
<a class="anchor" id="ab169de39462599fcb59ff956cbbd6b5b"></a><!-- doxytag: member="lwos.h::task_yield_to" ref="ab169de39462599fcb59ff956cbbd6b5b" args="(n)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="lwos_8h.html#ab169de39462599fcb59ff956cbbd6b5b">task_yield_to</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">n</td><td>)</td>
          <td>&#160;&#160;&#160;longjmp(<a class="el" href="lwos_8h.html#a3b6d2a771ddc14909fe529c79622be1f">task_current</a>-&gt;yieldbuf,(n)+1)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Yield to a specific task (or next lowest priority that is ready) </p>

</div>
</div>
<hr/><h2>Typedef Documentation</h2>
<a class="anchor" id="af41b315a18a5782b8182db98ab85c5b7"></a><!-- doxytag: member="lwos.h::Task" ref="af41b315a18a5782b8182db98ab85c5b7" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="struct__task.html">_task</a>  <a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Each row of the <em>task_table</em> contains data about the task. </p>

</div>
</div>
<hr/><h2>Enumeration Type Documentation</h2>
<a class="anchor" id="a724f9ce2351c125b3b7f6c7923822bce"></a><!-- doxytag: member="lwos.h::TaskState" ref="a724f9ce2351c125b3b7f6c7923822bce" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="lwos_8h.html#a724f9ce2351c125b3b7f6c7923822bce">TaskState</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>State of a task (stopped, ready, or waiting on an event) </p>
<dl><dt><b>Enumerator: </b></dt><dd><table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" id="a724f9ce2351c125b3b7f6c7923822bcea52340c1844b9c87b6c965569f21d72f1"></a><!-- doxytag: member="TASK_STOPPED" ref="a724f9ce2351c125b3b7f6c7923822bcea52340c1844b9c87b6c965569f21d72f1" args="" -->TASK_STOPPED</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a724f9ce2351c125b3b7f6c7923822bceaebcd951a6127c3c50a4f197b2b637793"></a><!-- doxytag: member="TASK_READY" ref="a724f9ce2351c125b3b7f6c7923822bceaebcd951a6127c3c50a4f197b2b637793" args="" -->TASK_READY</em>&nbsp;</td><td>
</td></tr>
<tr><td valign="top"><em><a class="anchor" id="a724f9ce2351c125b3b7f6c7923822bceaed346ef57a002d0957c75cb3a8888025"></a><!-- doxytag: member="TASK_WAIT" ref="a724f9ce2351c125b3b7f6c7923822bceaed346ef57a002d0957c75cb3a8888025" args="" -->TASK_WAIT</em>&nbsp;</td><td>
</td></tr>
</table>
</dd>
</dl>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a2d5f6c88428ff65ce252e63964752e76"></a><!-- doxytag: member="lwos.h::task_init" ref="a2d5f6c88428ff65ce252e63964752e76" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="lwos_8h.html#a2d5f6c88428ff65ce252e63964752e76">task_init</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Start LWOS -- typically called from default main. </p>

</div>
</div>
<hr/><h2>Variable Documentation</h2>
<a class="anchor" id="a3b6d2a771ddc14909fe529c79622be1f"></a><!-- doxytag: member="lwos.h::task_current" ref="a3b6d2a771ddc14909fe529c79622be1f" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a>* <a class="el" href="lwos_8h.html#a3b6d2a771ddc14909fe529c79622be1f">task_current</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Pointer to current task. </p>
<p>Current running task (used by many macros; also passed as an argument to the task </p>

</div>
</div>
<a class="anchor" id="a48e853cd9284d45e9af1203802dad496"></a><!-- doxytag: member="lwos.h::task_max" ref="a48e853cd9284d45e9af1203802dad496" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned <a class="el" href="lwos_8h.html#a48e853cd9284d45e9af1203802dad496">task_max</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Number of entries in the task table. </p>

</div>
</div>
<a class="anchor" id="a7c6e943398bf748ba97367e4b250d56f"></a><!-- doxytag: member="lwos.h::task_num" ref="a7c6e943398bf748ba97367e4b250d56f" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned <a class="el" href="lwos_8h.html#a7c6e943398bf748ba97367e4b250d56f">task_num</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Current running task (as an index into <em>task_table</em>) </p>

</div>
</div>
<a class="anchor" id="a68b9925cf8d8141dbab91504b96f9ffd"></a><!-- doxytag: member="lwos.h::task_table" ref="a68b9925cf8d8141dbab91504b96f9ffd" args="[]" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="lwos_8h.html#af41b315a18a5782b8182db98ab85c5b7">Task</a> <a class="el" href="lwos_8h.html#a68b9925cf8d8141dbab91504b96f9ffd">task_table</a>[]</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>The table of tasks. </p>

</div>
</div>
<a class="anchor" id="abbf01dbc8a3f47fd82f6c2afd53987ca"></a><!-- doxytag: member="lwos.h::task_tick" ref="abbf01dbc8a3f47fd82f6c2afd53987ca" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="lwos_8h.html#abbf01dbc8a3f47fd82f6c2afd53987ca">task_tick</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>User defined tick counter (must be signed) </p>
<p>This is set by (usually) one user task to represent time in some way (e.g., # of seconds or milliseconds) </p>

</div>
</div>
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Mon Nov 19 2012 22:30:11 for Lightweight OS (LWOS) by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
